from functools import wraps
from flask import g


def root_required(func):
    @wraps(func)
    def wrapper(*args, **kwargs):
        if hasattr(g, 'user') and (g.user.power == 1 or g.user.power == 0):
            return func(*args, **kwargs)
        else:
            return "权限不符"

    return wrapper
